package top.malegod.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.malegod.mapper.OtherMapper;
import top.malegod.model.Category;
import top.malegod.model.Comments;
import top.malegod.model.Integral;
import top.malegod.model.Rank;
import top.malegod.service.OtherService;
import top.malegod.utils.ServerResponse;

import java.util.List;

/**
 * Create by IntelliJ IDEA
 *
 * @author: AbelEthan
 * @date-Time: 2018/6/7 19:03
 * @description:
 */
@Service
public class OtherServiceImpl implements OtherService {

    @Autowired
    private OtherMapper otherMapper;

    @Override
    public ServerResponse findUserIntegral(String uerId) {
        Integral integral =  otherMapper.getUserIntegral(uerId);
        if (integral == null){
            return ServerResponse.createError("error");
        }
        return ServerResponse.createSuccess(integral);
    }

    @Override
    public ServerResponse findUserRank(String id) {
        Rank rank = otherMapper.getUserRank(id);
        if (rank == null){
            return ServerResponse.createError("error");
        }
        return ServerResponse.createSuccess(rank);
    }

    @Override
    public ServerResponse findCategoryName(String id) {
        Category category = otherMapper.getUserCategory(id);
        if (category == null){
            return ServerResponse.createError("error");
        }
        return ServerResponse.createSuccess(category);
    }

    @Override
    public ServerResponse findUserComments(String userId) {
        List<Comments> comments = otherMapper.getUserComments(userId);
        if (comments != null){
            return ServerResponse.createSuccess(comments);
        }
        return ServerResponse.createError("error");
    }
}
